table.insert(itemActions,
	function(item, action)
		-- MAGIC armors
		-- see: dir .. "readme.txt" for information regarding these variables
		local priority = 4
		local identify = true
		local dump = true

		if not isMagicArmor(item) then
			return false
		elseif action == aPICK and (not item.flags.Identified or isGoodMagicArmor(item)) then
			return priority
		elseif action == aIDENT then
			return identify
		elseif action == aSELL and item.flags.Identified and not isGoodMagicArmor(item) then
			return true
		elseif action == aDUMP and item.flags.Identified and not isGoodMagicArmor(item) then
			return dump
		end

		return false
	end
)

function isMagicArmor(item)
   if  (
         (item.quality == ItemQuality.Magic) and
         (item.baseItem.code == "uld" or -- Kraken
         item.baseItem.code == "upl" or -- Balrog
         item.baseItem.code == "urs" or -- Hauberk
         item.baseItem.code == "uhn" or -- Boneweave
         item.baseItem.code == "ung" or -- Diamond
         item.baseItem.code == "ula" or -- Scarab
         item.baseItem.code == "utu" or -- Wire
         item.baseItem.code == "uea" or -- Wyrm
         item.baseItem.code == "utp" or -- Archon
         item.baseItem.code == "uui" or -- Dusk
         item.baseItem.code == "uar" or -- Sacred
         item.baseItem.code == "xtp") -- Mage Plate
      ) then
      return true
   end
   return false
end


function isGoodMagicArmor(item)
	def, life = false, 0
	

	for i = 0, item.mods:size() - 1 do
		if item.mods[i].Stat.Type == StatType.MaxLife then
			life = item.mods[i].Value                 -- life mod
	elseif (item.mods[i].Stat.Type == StatType.DefensePercent and
		   item.mods[i].Value >=80) then -- 150-200% Enhanced Defense (Holy/Godly)
			def = true
	end
end

	return (
		   	hasCertainSockets(item, "34") or  -- artisans/jewelers armor
			def or
			life >= 50
			)
end